package day25;// write your code here
import java.util.Scanner;

/**
 * 星际密码
 */

/**
 * 6
 * 18 15 21 13 25 27
 * 5
 * 1 10 100 1000 10000
 */
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[10001];
        arr[1] = 1;
        arr[2] = 2;
        for (int i = 3; i < arr.length; i++) {
            arr[i] = (arr[i - 1] + arr[i - 2]) % 10000;
        }
        while(sc.hasNext()) {
            int n = sc.nextInt();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                sb.append(String.format("%04d", arr[x]));
            }
            System.out.println(sb);
        }
    }
}


